<?xml version="1.0"?>
<ScatterFile xmlns="http://schemas.microsoft.com/netmf/ScatterfileSchema.xsd">

    <Set Name="Valid" Value="false"/>

    <!-- ################################################################################ -->

    <Set Name="Stack_Bottom"    Value="0x081FE000"/>
    <Set Name="Stack_Top"       Value="0x081FFFF8"/>

    
    <If Name="TARGETLOCATION" In="FLASH">

        <Set Name="Code_BaseAddress" Value="0x10000000"/>
        <Set Name="Code_Size"        Value="0x00040000"/>
        <Set Name="Valid"            Value="true"/>

    </If>

    <If Name="TARGETLOCATION" In="RAM">

        <Set Name="Code_BaseAddress" Value="0x08200000"/> 
        <Set Name="Code_Size"        Value="0x00040000"/>
        <Set Name="Valid"            Value="true"/>
        
    </If>


    <!-- ################################################################################ -->

    <If Name="Valid" Value="false">
        <Error Message="Configuration not recognized"/>
    </If>

    <!-- we start at 0x10080000 since PortBooter lives at 0x10000000 -->
    <!-- the address and sizes for both load regions (LR_*) are chosen to start and completely fill a flash partition in the 28F320W18 flash chip -->


    <NamedGroup Name="MEMORY">
      <LoadRegion Name="LR_%TARGETLOCATION%" Base="%Code_BaseAddress%" Size="%Code_Size%"/>
      <LoadRegion Name="STACK" Base="%Stack_Bottom%" Size="%Stack_Top - Stack_Bottom% + 1"/>
    </NamedGroup>

    <EntryPoint Name="EntryPoint"/>

    <NamedGroup Name="SECTIONS">
      <ExecRegion Name="ER_%TARGETLOCATION%" Options="&gt;LR_%TARGETLOCATION%">
        <FileMapping Name="*" Options="(i.EntryPoint)" />
        <FileMapping Name="*" Options="(i.*)" />
        <FileMapping Name="*" Options="(SectionForBootstrapOperations)" />
      </ExecRegion>

      <ExecRegion Name="ER_RAM_RO" Align="0x10" Options="&gt;LR_%TARGETLOCATION%">
        <FileMapping Name="*" Options="(VectorsTrampolines)" />
        <FileMapping Name="*" Options="(.text*)" />
        <FileMapping Name="*" Options="(.rodata*)" />
        <FileMapping Name="*" Options="(rodata)" />
        <FileMapping Name="*" Options="(.constdata*)" />
        <FileMapping Name="*" Options="(.conststring*)" />
        <FileMapping Name="*" Options="(SectionForFlashOperations)" />

        <!-- libc thinks that it needs these routines, but they are never called -->
        <Include File="%SPOCLIENT%\Solutions\%PLATFORM%\scatterfile_gcc_missing_symbols.xml"/>
      </ExecRegion>
      <ExecRegion Name="ER_RAM_RW" Align="0x10" Options="&gt;LR_%TARGETLOCATION%">
        <FileMapping Name="*" Options="(rwdata)" />
        <FileMapping Name="*" Options="(.data*)" />
        <FileMapping Name="*" Options="(.zidata*)" />
      </ExecRegion>
      <ExecRegion Name=".bss" Align="0x10" Options="&gt;LR_%TARGETLOCATION%">
        <FileMapping Name="*" Options="(.bss*)" />
        <Provide Name="__exidx_start" />
        <Provide Name="__exidx_end" />
      </ExecRegion>
      <ExecRegion Name="/DISCARD/">
        <FileMapping Name="*" Options="(.glue*)" />
        <FileMapping Name="*" Options="(.vfp11*)" />
        <FileMapping Name="*" Options="(.ARM.exidx*)" />
        <FileMapping Name="*" Options="(.ARM.extab*)" />
      </ExecRegion>  
      <ExecRegion Name="ER_STACK_BOTTOM" Base="%Stack_Bottom%">
        <FileMapping Name="*" Options="(SectionForStackBottom)" />
      </ExecRegion>
      <ExecRegion Name="ER_STACK_TOP" Base="%Stack_Top%">
        <FileMapping Name="*" Options="(SectionForStackTop)" />
      </ExecRegion>
    </NamedGroup>

    <!-- The following variables are used to simulate the ones autogenerated by RVDS -->
    <GlobalVariable Name="Load$$ER_%TARGETLOCATION%$$Base"          Value="ADDR(ER_%TARGETLOCATION%)"/>
    <GlobalVariable Name="Image$$ER_%TARGETLOCATION%$$Length"       Value="SIZEOF(ER_%TARGETLOCATION%)"/>
    <GlobalVariable Name="Image$$ER_RAM_RO$$Base"                   Value="ADDR(ER_RAM_RO)"/>
    <GlobalVariable Name="Image$$ER_RAM_RO$$Length"                 Value="ADDR(ER_RAM_RW) - ADDR(ER_RAM_RO)"/>
    <GlobalVariable Name="Load$$ER_RAM_RO$$Base"                    Value="LOADADDR(ER_RAM_RO)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$Base"                   Value="ADDR(ER_RAM_RW)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$Length"                 Value="(ADDR(.bss) + SIZEOF(.bss)) - ADDR(ER_RAM_RW)"/>
    <GlobalVariable Name="Load$$ER_RAM_RW$$Base"                    Value="LOADADDR(ER_RAM_RO) + (ADDR(ER_RAM_RW) - ADDR(ER_RAM_RO))"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Base"               Value="ADDR(.bss)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Length"             Value="SIZEOF(.bss)"/>
    <GlobalVariable Name="__use_no_semihosting_swi"                 Value="0"/>

</ScatterFile>
